<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .zero{
            width: 100px;
            height: 100px;
            border: 1px solid #cccccc;
            overflow: hidden;
            
        }
        .one{
            width: 500%;
            height: 100%;
            display: block;
            
        }
        .two{
            width: 20%;
            height: 100%;
            float: left;
        }
    </style>
</head>
<body>
    <div class="zero">
        <div class="one">
            <div class="two" style="background-color:red ;"></div>
            <div class="two" style="background-color:blue ;"></div>
            <div class="two" style="background-color:yellow ;"></div>
            <div class="two" style="background-color:green ;"></div>
            <div class="two" style="background-color:black ;"></div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script>
        $(function(){
            console.log("haha");
            
            var time;
            var offset=0
            function autoplay(){
                setInterval(function(){

                    offset-=100
                    if(offset<=-400){
                        offset=0
                    }
                    $(".one").animate({marginLeft:offset+"%"})
                    
                },5000)
            }
            autoplay()
        })
    </script>   
       
    
</body>
</html>